<template>
	<div class="bill">
		<view class="list" v-for="(item,index) of data" :key="index">
			<view class="list-l">
				<text>订单状态</text>
				<text v-if="item.status===1">
					待审核
				</text>
				<text v-if="item.status===2">
					已完成
				</text>
				<text v-if="item.status===3">
					失败
				</text>
			</view>
			<view class="list-l">
				<text v-if="item.type===1">内部转账</text>
				<text v-if="item.type===2">链上提币</text>
				<text class="black">{{item.quantity}}zkb</text>
			</view>
			<view class="list-l">
				<text>手续费</text>
				<text class="black">{{item.fee}}zkb</text>
			</view>
			<view class="list-l">
				<text>订单ID：{{item.order_id}}</text>
				<text class="copy">复制</text>
			</view>
			<view class="list-l">
				<text>目标地址：{{item.member_account}}</text>
				<text class="copy">复制</text>
			</view>
			<view class="list-l">
				<text v-if="item.status===2">完成时间</text>
				<text v-else>创建时间</text>
				<text v-if="item.status===2">{{formatDate(item.complete_time*1000)}}</text>
				<text v-else>{{formatDate(item.create_time*1000)}}</text>
			</view>
			<view class="list-l">
				<text>订单备注</text>
				<text>{{item.remarks}}</text>
			</view>
		</view>
		<block-loading :status="status" :len="data.length"></block-loading>
	</div>
</template>

<script>
	import {transferOrders} from "@/api/record.js"
	import {formatDate} from "@/utils/util.js"
	export default{
		name:"bill",
		data(){
			return{
				data:[],
				status:"loading",
				page:1
			}
		},
		mounted() {
			this.getData()
		},
		//上拉加载
		onReachBottom(){
			this.getData()
		},
		methods:{
			formatDate(value){
				return formatDate(value)
			},
			async getData(){
				let res = await transferOrders({page:this.page,size:20});
				if(this.page===1&&res.data.length === 0){
					this.status = "nodata"
					return
				}
				if(this.page===1&&res.data.length > 0 && res.data.length < 20){
					this.status = "nomore"
				}
				if(res.data.length === 0){
					this.status = "nomore"
					return;
				}
				this.page++;
				this.data = this.data.concat(res.data);
			},
		}
	}
</script>

<style lang="less" scoped src="./bill.less">
</style>
